package org.nf.shopping.controller;

import com.github.pagehelper.PageInfo;
import lombok.RequiredArgsConstructor;
import org.nf.shopping.common.vo.ResultVO;
import org.nf.shopping.entity.Order;
import org.nf.shopping.service.OrderService;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @Author czl
 * @Date 2024-12-18
 */
@RestController
@RequiredArgsConstructor
@RequestMapping("/order")
public class OrderController extends BaseController{
    
    private final OrderService orderService;

    @GetMapping("/listOrder")
    public ResultVO<PageInfo<Order>> listOrder(Integer limit, Integer page, String id){
        PageInfo<Order> pageInfo = orderService.listOrder(limit, page, id);
        return success(pageInfo);
    }

    @PostMapping("/updateOrder")
    public ResultVO updateOrder(Order order){
        orderService.updateOrder(order);
        return success();
    }

    @PostMapping("/deloneOrder")
    public ResultVO deloneOrder(Integer id){
        orderService.deloneOrder(id);
        return success();
    }

    @PostMapping("/addOrder")
    public ResultVO addOrder(Order order){
        orderService.addOrder(order);
        return success();
    }

    @PostMapping("/getOrderList")
    public ResultVO<List<Order>> getOrderList(){
        return success(orderService.getOrderList());
    }
}
